package org.example.exception;


import io.micrometer.common.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.example.dto.ResultDTO;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.yaml.snakeyaml.constructor.DuplicateKeyException;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 异常处理器
 *
 * @author
 */
@RestControllerAdvice
@Slf4j
public class BaseExceptions {

	/**
	 * 处理自定义异常
	 */
	@ExceptionHandler(BizException.class)
	public ResultDTO<Void> handlerException(BizException e){
		log.error(e.getMessage(), e);
		return ResultDTO.fail(e);
	}


	@ExceptionHandler(Exception.class)
	public ResultDTO<Void> handleException(Exception e){
		log.error(e.getMessage(), e);
		return ResultDTO.fail();
	}


}
